var ns, app;
app = new Vue({
    el: '#app',
    data: {
         list: [],
        form: {
            pageindex: 0,
            pagesize: 10,
        },
        status: 1,
        current_item_length: 0,
        is_searching: false,
        scroll_top: 0,
        can_scroll: false,
    },
    methods: {
        get_data: function() {
            var that = this;
            that.is_searching = true;
            that.can_scroll = false;
            var options = {};
            options.action = "getvisithistorylist";
            options.pagesize = that.form.pagesize;
            options.pageindex = that.form.pageindex;
            options.type = that.status;
            ns.post(options, function (succeed, data, err) {
                that.is_searching = false;
                if (succeed) {
                    if (data.list.length == that.form.pagesize) {
                        that.can_scroll = true;
                    }
                    if (that.form.pageindex == 0) {
                        that.list = data.list;
                    } else {
                        that.list = that.list.concat(data.list);
                    }
                    app.current_item_length = that.list.length
                } else if (err) {
                    that.list = [];
                    that.current_item_length = 0;
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }, {
                toast: true
            });
        },
        select_status: function(status) {
            var that = this;
            that.status = status;
            that.get_data();
        },
        open_details: function(item) {
            ns.openWin('gate_sentry_details_frm', '门岗通行记录', {
                id: item.ID
            });
        },
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    ns.init_pull();
    setTimeout(function() {
        app.get_data();
    }, 500)
};
